-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang][Builtin] add __builtin_exit #74803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: None (W-50243) ChangesAdd __builtin_exit in Full diff: https://github.com/llvm/llvm-project/pull/74803.diff 2 Files Affected:
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index ec39e926889b9..8b73e9c5e3594 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -948,6 +948,7 @@ BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
// Random libc builtins.
+BUILTIN(__builtin_exit, "vi", "Fnr")
BUILTIN(__builtin_abort, "v", "Fnr")
BUILTIN(__builtin_index, "c*cC*i", "Fn")
BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
diff --git a/clang/test/CodeGen/builtin-exit-test.c b/clang/test/CodeGen/builtin-exit-test.c
new file mode 100644
index 0000000000000..1ece90de1aa4f
--- /dev/null
+++ b/clang/test/CodeGen/builtin-exit-test.c
@@ -0,0 +1,9 @@
+//RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -Wno-strict-prototypes -triple aarch64-target-linux-gnu %s -o - | FileCheck %s
+
+//CHECK: define dso_local void @test() #0 {
+//CHECK: call void @exit(i32 noundef 1)
+//CHECK: unreachable
+
+void test(void){
+ __builtin_exit(1);
+}
|
|
This comes down to a question of 'why' from me? Typically we add builtins like this because libc++ need them, or libc/libstdc++ use them. In this case, I don't see any evidence of anyone really needing it. While GCC supports it, I don't really see value here? Also, this is adding for ALL platforms, so this is something that needs to be validated for all platforms as well (as far as runtime testing). |
|
I added __builtin_exit() because __builtin_exit() was used in some projects when I switched from GCC to LLVM. I don't think this is an isolated case, because the __builtin_exit() function is still widely used.https://sourcegraph.com/search?q=context:global+__builtin_exit&patternType=standard&sm=1&groupBy=repo |
|
I'm not really convinced that |
|
Closing, since it seems to be abandoned. |
Add __builtin_exit in
clang/include/clang/Basic/Builtins.def. It works perfectly on arm64be and arm64le.